﻿#ifndef __AVOID_BW_CONTROL_BUTTON_HEAD_FILE_INCXLUDED__
#define __AVOID_BW_CONTROL_BUTTON_HEAD_FILE_INCXLUDED__
#include "interface/IFont.h"
#include "interface/IDrag.h"
#include "interface/IUserDraw.h"
#include "interface/IRound.h"
#include "interface/ISmoothTransform.h"

namespace swui
{
#pragma warning(push)
#pragma warning(disable:4250)
	class ctlButton : virtual public ctlRoot, 
		public IFont, public IDrag, public IRound, 
		public IUserDraw, public ISmoothTransform
	{
	public:
		static const ctlControlType uniqueType = ctlControlType::ctlButton;
	public:
		virtual ~ctlButton() { destroy(); }
		bool create(ctlRoot* parent, ctlRect rect, 
			const ctlText& lpszText = ctlText(L""), 
			const ctlStyleBase& = ctlStyleGradient(ctlStyleGradient::common));
	public:
		ctlDirection getTextJudgeMode();
		void setTextJudgeMode(ctlDirection);
		void setAsStatic(bool);
		bool isAsStatic();
	public:
		//设置按钮是否有选中和未选中区别
		void enableSelected(bool);
		bool isSelectedEnabled();
		bool isSelected();
		void setSelected(bool);
		void setSelectedStyle(const ctlStyleBase&);
		std::shared_ptr<ctlStyleBase> getSelectedStyle();
		ctlStyleBase& getSelectedStyleRef();
	public:
		virtual bool setText(const ctlText& lpszText);
	protected:
		virtual void _mouse_event_(ctlMouseEvent* me);
		virtual void _redraw_(_ctlInterior::drawInfo*);
		void _calc_text_rectangle_(bool=true);
		virtual void _flush_font_();
		virtual void _position_event_(ctlPositionEvent* pe);
	private:
		ctlDirection _judgeMode;
		ctlRect _textRect;
		bool _button_as_static;
		bool _button_selectedable;
		bool _button_selected;
		std::shared_ptr<ctlStyleBase> _button_style;
	};
#pragma warning(pop)
}

#endif